package com.nondo.rdp.finance.model.course;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.nondo.rdp.auth.model.UserBeanInner;
import com.nondo.rdp.core.common.BeanUtils;
import com.nondo.rdp.core.model.AttachBean;
import com.nondo.rdp.finance.domain.course.Course;

public class CourseBean {
	private Long id; // 课程ID
	private String name;// 课程名称
	private String description;// 课程简介
	private AttachBean descImg; // 简介图片
	private int type; // 类型：0课程；1资讯
	private String teacher;// 讲师
	private String introduction; //讲师简介
	private UserBeanInner user; // 发布人
	private Integer free;// 是否免费
	private float price;// 当前价格
	private float origPrice;// 原始价格
	private int auditStatus;// 审核状态0：未审核；1：通过;2:驳回
	private AttachBean mainImg; // 封面图片
	private Date publishDate;// 发布时间
	private int status;// 上架状态0:下架；1：上架
	private Integer recommend;// 是否推荐
	private Date recommendDate;// 推荐日期
	private float rate;// 平均评分分数
	private int sortNum;// 排序
	private int home;// 是否放置首页
	private Date createDate; // 创建日期
	private int isBuy; // 已购0|1
	private int pclassifyId; //父分类ID
	private int classifyId; // 子分类ID
	private String buyButtonStatus; // 购买按钮状态

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public AttachBean getDescImg() {
		return descImg;
	}

	public void setDescImg(AttachBean descImg) {
		this.descImg = descImg;
	}

	public String getTeacher() {
		return teacher;
	}

	public void setTeacher(String teacher) {
		this.teacher = teacher;
	}

	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	public UserBeanInner getUser() {
		return user;
	}

	public void setUser(UserBeanInner user) {
		this.user = user;
	}

	public Integer getFree() {
		return free;
	}

	public void setFree(Integer free) {
		this.free = free;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public float getOrigPrice() {
		return origPrice;
	}

	public void setOrigPrice(float origPrice) {
		this.origPrice = origPrice;
	}

	public int getAuditStatus() {
		return auditStatus;
	}

	public void setAuditStatus(int auditStatus) {
		this.auditStatus = auditStatus;
	}

	public AttachBean getMainImg() {
		return mainImg;
	}

	public void setMainImg(AttachBean mainImg) {
		this.mainImg = mainImg;
	}

	public Date getPublishDate() {
		return publishDate;
	}

	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Integer getRecommend() {
		return recommend;
	}

	public void setRecommend(Integer recommend) {
		this.recommend = recommend;
	}

	@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
	public Date getRecommendDate() {
		return recommendDate;
	}

	public void setRecommendDate(Date recommendDate) {
		this.recommendDate = recommendDate;
	}

	public float getRate() {
		return rate;
	}

	public void setRate(float rate) {
		this.rate = rate;
	}

	public int getSortNum() {
		return sortNum;
	}

	public void setSortNum(int sort) {
		this.sortNum = sort;
	}

	public int getHome() {
		return home;
	}

	public void setHome(int home) {
		this.home = home;
	}

	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public int getIsBuy() {
		return isBuy;
	}

	public void setIsBuy(int isBuy) {
		this.isBuy = isBuy;
	}
	
	public int getPclassifyId() {
		return pclassifyId;
	}

	public void setPclassifyId(int pclassifyId) {
		this.pclassifyId = pclassifyId;
	}

	public int getClassifyId() {
		return classifyId;
	}

	public void setClassifyId(int classifyId) {
		this.classifyId = classifyId;
	}

	public String getBuyButtonStatus() {
		return buyButtonStatus;
	}

	public void setBuyButtonStatus(String buyButtonStatus) {
		this.buyButtonStatus = buyButtonStatus;
	}

	public static CourseBean covert2Bean(Course course) {
		CourseBean courseBean = new CourseBean();
		BeanUtils.copy(course, courseBean);
		AttachBean descImg = courseBean.getDescImg();
		String orginPath = descImg.getPath();
		if (orginPath.indexOf("https") == -1) {
			descImg.setPath(orginPath.replace("http", "https"));
		}
		return courseBean;
	}

}
